package com.waitingsnow.modules.shell.controller
{
import com.waitingsnow.core.mvc.controller.command;
import com.waitingsnow.modules.shell.ShellFacade;
import com.waitingsnow.modules.shell.model.RubyServerProxy;
import com.waitingsnow.modules.shell.model.events.RubyServerProxyEvent;
import com.waitingsnow.modules.shell.view.ShellView;

/**
 * 
 * @author waitingsnow
 * $Id: ShellCommand.as 2 2012-05-17 10:10:03Z cgslendy@gmail.com $
 */
public class ShellCommand extends command
{
	//==========================================================================
	//  Constructor
	//==========================================================================
	/**
	 * Constructs a new <code>ShellStartUpCommand</code> instance.
	 * 
	 */
	public function ShellCommand()
	{
		super();
	}
	
	//==========================================================================
	//  Variables
	//==========================================================================
	private var rubyServerProxy:RubyServerProxy;
	private var shellView:ShellView;
	private var facade:ShellFacade = ShellFacade.getInstance();
	
	//==========================================================================
	//  Methods
	//==========================================================================
	override protected function execute():void
	{
		shellView = facade.getContent(ShellView.NAME) as ShellView;
		rubyServerProxy = facade.getContent(RubyServerProxy.NAME) as RubyServerProxy;
		rubyServerProxy.addEventListener(RubyServerProxyEvent.GET_RUBY_SERVER_DATA, 
			getRubyServerDataHandler);
		rubyServerProxy.getRubyServerData();
	}
	
	private function getRubyServerDataHandler(event:RubyServerProxyEvent):void
	{
		shellView.setRubyServerData(rubyServerProxy.rubyServerVO);
	}
}
}